package com.bijiawang.user.controller;

import com.bijiawang.user.bean.Userinfo;
import com.bijiawang.user.service.UserinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Controller
public class UserinfoController {

    @Autowired
    UserinfoService userinfoService;

    @GetMapping("/ToUserInfo/{Username}")
    public String ToUserInfo(@PathVariable("Username") String username, Model model){
        Userinfo userinfo = userinfoService.getUserinfoByUserName(username);
        if (userinfo == null){
            userinfo = userinfoService.getUserinfoByPhoneNumber(username);
        }
        String phonenumber = userinfo.getPhonenumber();
        String email = userinfo.getEmail();
        model.addAttribute("phonenumber",phonenumber);
        model.addAttribute("email",email);
        return "UserInFo";
    }



}
